<%@page import="java.util.HashMap"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%
	String userId = null;
	if (session.isNew()
			|| (Boolean) session.getAttribute("isLogin") == false) {
		response.sendRedirect("../index.jsp");
	} else {
		userId = (String) session.getAttribute("userId");
	}
	HashMap<String, Object> dailyData = (HashMap<String, Object>) request
			.getAttribute("dailyData");
%>
</head>
<link rel="stylesheet" type="text/css" href="../css/dailymission.css" />
<script src="../js/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
	var check_cnt = 0;
	var check_sns = false;
	$(document).ready(function() {
		$.ajax({
			method : "GET",
			url : "../ajaxQuery.do",
			data : "checkoauth=true",
			success : responseOauthData
		});

		$("#sns_check").change(function() {
			check_cnt++;
			if (1 == check_cnt % 2 && check_sns == true) {
				//Oauth Access token 이 있을시에				
			
				//			$.ajax({
				//				method : "GET",
				//				url : "../ajaxQuery.do",
				//				data : "checksns="+check_sns,
				//				success : responseOauthData

				alert("이미 Twitter 인증이 되었습니다.");
			} else if (1 == check_cnt % 2 && check_sns == false) {
				//Oauth Access token 이 없을시에
				var answer = confirm("Twitter 인증을 하시겠습니까?")
				if (answer){
					window.location = "oauth1stphase.jsp";
				}
				else{
					window.location.reload();
				}
			}
		});
	});
	function responseOauthData(data) {
		if(data.token != "null&null") {
		check_sns = true;			
		}
	};
</script>
<body>
<div id="set">
	<jsp:include page="logonmenu.jsp"></jsp:include>
<div id="line">
<div id="dailymission">
	<img src="../dailymission.png"height=100>
	</div>
	<div id="tab">
	<div id="header">
		<div>
			UserId :
			<%=userId%>
		</div>
		<div>
			Program Name :
			<%=dailyData.get("programid")%></div>

	</div>
	<form action="dailymission.do" method="post">
		<input type="hidden" name="programid"
			value="<%=dailyData.get("programid")%>" /> 오늘의 체중 : <input
			type="text" name="todayweight" />
		<table border="1">
			<thead>
				<tr>
					<th colspan="3">Today Mission</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td colspan="3">식단</td>
				</tr>
				<tr>
					<td>아침</td>
					<td><%=dailyData.get("foodName1")%></td>
					<td>Success!<input type="radio" name="foodlist1" value="T">
						Fail!<input type="radio" name="foodlist1" value="F" checked>
					</td>
				</tr>
				<tr>
					<td>점심</td>
					<td><%=dailyData.get("foodName2")%></td>
					<td>Success!<input type="radio" name="foodlist2" value="T">
						Fail!<input type="radio" name="foodlist2" value="F" checked>
					</td>
				</tr>
				<tr>
					<td>아침</td>
					<td><%=dailyData.get("foodName3")%></td>
					<td>Success!<input type="radio" name="foodlist3" value="T">
						Fail!<input type="radio" name="foodlist3" value="F" checked>
					</td>
				</tr>
				<tr>
					<td colspan="3">운동</td>
				</tr>
				<tr>
					<td>운동1</td>
					<td><%=dailyData.get("exerName1")%></td>
					<td>Success!<input type="radio" name="exerlist1" value="T">
						Fail!<input type="radio" name="exerlist1" value="F" checked>
					</td>
				</tr>
				<tr>
					<td>운동2</td>
					<td><%=dailyData.get("exerName2")%></td>
					<td>Success!<input type="radio" name="exerlist2" value="T">
						Fail!<input type="radio" name="exerlist2" value="F" checked>
					</td>
				</tr>
				<tr>
					<td>운동3</td>
					<td><%=dailyData.get("exerName3")%></td>
					<td>Success!<input type="radio" name="exerlist3" value="T">
						Fail!<input type="radio" name="exerlist3" value="F" checked>
					</td>
				</tr>
			</tbody>
		</table>
		<div id="comment">
			<textarea rows="5" cols="31" id="comment" name="comment"></textarea>
		</div>
		<div id="buttons">
			<input type="checkbox" id="sns_check" name="sns_check"/><img style="width: 30px;"
				src="../twt_icon.png" />
			<button type="submit" class="button yellowgreen">Submit</button>
			<button type="reset" class="button yellowgreen">Reset</button>
		</div>
	</form>
	</div>
	<div id="logo">
	<img src="../gogologo.png" width=200, height=200>
	</div>
	</div>
</div>
</body>
</html>